﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Gollie.Controls
{
	public partial class PageContent : BaseUserControl
	{
		protected override void PreLoadHandler(object sender, EventArgs e)
		{
			this.SetMenu();
		}

		private void SetMenu()
		{
			UserInfo userInfo = UserInfo;
			if (userInfo == null)
			{
				this.Menu1.MenuName = "visitor";
			}
			else
			{
				switch (userInfo.Role)
				{
					case Role.SuperUser: this.Menu1.MenuName = "siteadmin"; break;
					case Role.Sales: this.Menu1.MenuName = "sales"; break;
					case Role.Desk: this.Menu1.MenuName = "desk"; break;
					case Role.Customer: this.Menu1.MenuName = "customer"; break;
					case Role.Administrator: this.Menu1.MenuName = "administrator"; break;
				}
			}
		}

		public string MainControlClass
		{
			set
			{
				this.PlaceHolder1.Controls.Clear();

				//switch (value.ToLower())
				//{
				//	case "home.ascx":
				//		this.RightPadding = 150; //room for textlinks.
				//		break;
				//}

				this.PlaceHolder1.Controls.Add(LoadControl(value));
			}
		}

		public string Text
		{
			set
			{
				Label lbl = new Label();
				lbl.Text = value;

				this.PlaceHolder1.Controls.Add(lbl);
			}
		}

		public int RightPadding
		{
			set { this.ContentDiv.Style.Add("padding-right", value.ToString() + "px;"); }
		}

	}
}